#include <bits/stdc++.h>
using namespace std;
#define int __int128

long long m, x, a, b;
int n = 1;
const int p = 998244353;

int qpow(int a, int b) {
	int res = 1;
	while (b) {
		if (b & 1) res = res * a % p;
		b >>= 1;
		a = a * a % p;
	}
	return res;
}

signed main() {
	freopen("clown.in", "r", stdin);
	freopen("clown.out", "w", stdout);
	cin >> m;
	while (m--) {
		cin >> x;
		n *= x;
	}
	cin >> a >> b;
	if (n == 3) {
		int sum = qpow(a, n) * qpow(b, n * (n - 1) / 2) % p;
		int ans = n * ((int)a * a % p * b % p * b % p - (int)a * b % p) % p + (int)a * b % p;
		cout << (long long)(((sum - ans) % p + p) % p);
	} else if (n & 1) {
		int sum = qpow(a, n) * qpow(b, n * (n - 1) / 2) % p;
		int ans = n * (qpow(a, (n + 1) / 2) * qpow(b, (n - 1) * (n - 1) / 4 + (n - 1) / 2) % p - (int)a * b % p) % p + (int)a * b % p;
		cout << (long long)(((sum - ans) % p + p) % p);
	} else if (n == 4 && 0) {
		// 
	} else {
		int sum = qpow(a, n) * qpow(b, n * (n - 1) / 2) % p;
		int delta = n / 2;
		int ans1 = n / 2 * (qpow(a, n / 2 + 1) * qpow(b, (n * (n - 1) / 2 - delta) / 2 + delta) % p) % p;
		int ans2 = n / 2 * (qpow(a, n / 2) * qpow(b, (n * (n - 1) / 2 - delta) / 2 + delta) % p) % p;
		int ans3 = n * a % p * b % p * qpow(b, n / 2) % p;
		cout << (long long)(((sum - ans2 - ans1 + ans3) % p + p) % p);
	}
	return 0;
}
